package code.com.java.concurrent;

import java.util.concurrent.ArrayBlockingQueue;


/**
 * @author panjun
 * @date 2018/6/1.
 */
public class CterThreadPool {
	private static ArrayBlockingQueue<Runnable> blockingQueue = new ArrayBlockingQueue<Runnable>(10);
	
	
	public static void main(String[] args){
		
		Thread t1 = new Thread(new Runnable() {
			
			public void run() {
				try {
					Thread.sleep(100);
					Runnable runnable;
					while ((runnable = blockingQueue.take())!=null){
						runnable.run();

					}
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
				System.out.println("1");
				System.out.println(Thread.currentThread());
			}
		});
		t1.setDaemon(true);
		t1.run();
		t1.start();

		for (int i=0;i<10;i++){
			final int a = i;
			blockingQueue.offer(new Runnable() {
				
				public void run() {
					System.out.println("ִ�������� i:"+a);
				}
			});
		}

	}

}
